<h1>索取更多信息</h1>
<div class="feedback">
    <dl>
        <dt>*姓名：</dt>
        <dd><span><input type="text" id="sub_name"></span></dd>
    </dl>
    <dl>
        <dt>*邮箱：</dt>
        <dd><span><input type="text" id="sub_email"></span></dd>
    </dl>
    <dl>
        <dt>*电话：</dt>
        <dd><span><input type="text" id="sub_tel"></span></dd>
    </dl>
    <dl>
        <dt>备注（可选）：</dt>
        <dd><span><textarea type="text" id="sub_con"></textarea></span></dd>
    </dl>
    <dl>
        <dd><a href="javascript:;" id="submit">确定提交</a></dd>
    </dl>
</div>
<script>
    $("#submit").click(function () {

        var name = $("#sub_name").val();
        var email = $("#sub_email").val();
        var tel = $("#sub_tel").val();
        var con = $("#sub_con").val();

        var reg = /\w+[@]{1}\w+[.]\w+/;
        if (email == '' || email == undefined) {
            layer.alert("请输入email地址");
            return false;
        }
        if (!reg.test(email)) {
            layer.alert("请输入正确的email地址");
            return false;
        }
        var url = "/message_add";
        $.ajax({
            url: url,
            type: "post",
            data: {'name': name, 'tel': tel, 'email': email, 'con': con},
            dataType: 'json',
            success: function (data) {
                console.log(data);
                if (data.status == 1) {
                    layer.alert("留言成功", {
                        skin: 'layui-layer-lan'
                        , closeBtn: 1
                        , anim: 5 //动画类型
                    }, function (index) {
                        window.location.href = window.location.href;
                    });

                } else {
                    layer.alert("留言失败");
                }
            }
        });

    });
</script>